package cn.ronghuanet.auth.controller;

import cn.ronghuanet.auth.service.ILoginService;
import cn.ronghuanet.auth.vo.LoginVO;
import cn.ronghuanet.base.util.AjaxResult;
import cn.ronghuanet.org.domain.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private ILoginService loginService;

    @PutMapping
    public AjaxResult login(@RequestBody Employee employee){
        try {
            LoginVO login = loginService.login(employee);
            return AjaxResult.success(login);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.error(e.getMessage());
        }
    }
}
